import { AxiosResponse } from 'axios';
import axios from '../http';
// 登录
export const doLogApi = (data: { account: string; password: string }) => axios.post('user/login', data);

// 注册账号
export const doRegApi = (data: any) => axios.post('user/register', data);

// 获取验证码
export const getRegCode = (data: any) => axios.post('user/getcode', data);

// 修改密码
export const changePassword = (data: any) => axios.post('user/password', data);

// 权限详情
export type GetAuthParams = 'get' | 'getuse' | 'getlist';
export const getAuth = (commond: GetAuthParams) => axios.get(`auth/u?commond=${commond}`);

/**
 * ====================================
 *     用户管理
 * ====================================
 */
// 添加子账号
export const addUser = (data: { account: string; password: string; nickname: string }) =>
	axios.post('usermanager', data);

// 获取列表
export const getUserList: GetListApi<{}, {}> = (params) => axios.get('usermanager', { params });

// 删除
export const doDelApi = (uid: number, password: string) =>
	axios.delete('usermanager/' + uid, { params: { t: password } });

// 重置密码
export const resetPassword = (uid: Number) => axios.put('usermanager/' + uid);

// 修改封禁状态
export const changeBand = (uid: number, dis: number) => axios.post(`super/ban/${uid}/${dis}`);
